﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.RazorEngineHost
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.CodeDom;
using System.Collections.Generic;
using System.Web.Razor.Generator;
using System.Web.Razor.Parser;

namespace System.Web.Razor
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents the generated code for the razor engine host.</summary>
  public class RazorEngineHost
  {
    internal const string InternalDefaultClassName = "__CompiledTemplate";
    internal const string InternalDefaultNamespace = "Razor";
    private bool _instrumentationActive;
    private Func<ParserBase> _markupParserFactory;
    private int _tabSize = 4;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.RazorEngineHost" /> class.</summary>
    protected RazorEngineHost()
    {
      this.GeneratedClassContext = GeneratedClassContext.Default;
      this.NamespaceImports = (ISet<string>) new HashSet<string>();
      this.DesignTimeMode = false;
      this.DefaultNamespace = "Razor";
      this.DefaultClassName = "__CompiledTemplate";
      this.EnableInstrumentation = false;
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.RazorEngineHost" /> class.</summary>
    /// <param name="codeLanguage">The specified code language.</param>
    public RazorEngineHost(RazorCodeLanguage codeLanguage)
      : this(codeLanguage, (Func<ParserBase>) (() => (ParserBase) new HtmlMarkupParser()))
    {
    }

    /// <summary>Initializes a new instance of the <see cref="T:System.Web.Razor.RazorEngineHost" /> class.</summary>
    /// <param name="codeLanguage">The specified code language.</param>
    /// <param name="markupParserFactory">The markup parser factory.</param>
    public RazorEngineHost(RazorCodeLanguage codeLanguage, Func<ParserBase> markupParserFactory)
      : this()
    {
      if (codeLanguage == null)
        throw new ArgumentNullException(nameof (codeLanguage));
      if (markupParserFactory == null)
        throw new ArgumentNullException(nameof (markupParserFactory));
      this.CodeLanguage = codeLanguage;
      this._markupParserFactory = markupParserFactory;
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the generated class context for the host.</summary>
    /// <returns>The generated class context for the host.</returns>
    public virtual GeneratedClassContext GeneratedClassContext { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the namespace imports for the host.</summary>
    /// <returns>The namespace imports for the host.</returns>
    public virtual ISet<string> NamespaceImports { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the default base class for the host.</summary>
    /// <returns>The default base class for the host.</returns>
    public virtual string DefaultBaseClass { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets a value that indicates whether the mode designs a time for the host.</summary>
    /// <returns>true if the mode designs a time for the host; otherwise, false.</returns>
    public virtual bool DesignTimeMode { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the default class name for the host.</summary>
    /// <returns>The default class name for the host.</returns>
    public virtual string DefaultClassName { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the default namespace for the host.</summary>
    /// <returns>The default namespace for the host.</returns>
    public virtual string DefaultNamespace { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the static helpers for the host.</summary>
    /// <returns>The static helpers for the host.</returns>
    public virtual bool StaticHelpers { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the languages supported by the code generator.</summary>
    /// <returns>The languages supported that by the code generator.</returns>
    public virtual RazorCodeLanguage CodeLanguage { get; protected set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the host that enables the instrumentation.</summary>
    /// <returns>The host that enables the instrumentation.</returns>
    public virtual bool EnableInstrumentation
    {
      get => !this.DesignTimeMode && this._instrumentationActive;
      set => this._instrumentationActive = value;
    }

    /// <summary>Gets or sets whether the design time editor is using tabs or spaces for indentation.</summary>
    public virtual bool IsIndentingWithTabs { get; set; }

    /// <summary>Tab size used by the hosting editor, when indenting with tabs.</summary>
    public virtual int TabSize
    {
      get => this._tabSize;
      set => this._tabSize = Math.Max(value, 1);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the instrumented source file path for the host.</summary>
    /// <returns>The instrumented source file path for the host.</returns>
    public virtual string InstrumentedSourceFilePath { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates a markup parser using the specified language parser for the <see cref="T:System.Web.Razor.RazorEngineHost" />.</summary>
    /// <returns>A markup parser to create using the specified language parser for the <see cref="T:System.Web.Razor.RazorEngineHost" />.</returns>
    public virtual ParserBase CreateMarkupParser() => this._markupParserFactory != null ? this._markupParserFactory() : (ParserBase) null;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns the methods as language-specific Razor code parser using the specified language parser.</summary>
    /// <returns>The methods as language-specific Razor code parser using the specified language parser.</returns>
    /// <param name="incomingCodeParser">The C# or Visual Basic code parser.</param>
    public virtual ParserBase DecorateCodeParser(ParserBase incomingCodeParser) => incomingCodeParser != null ? incomingCodeParser : throw new ArgumentNullException(nameof (incomingCodeParser));

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns the method to decorate markup parser using the specified language parser.</summary>
    /// <returns>The method to decorate markup parser using the specified language parser.</returns>
    /// <param name="incomingMarkupParser">The C# or Visual Basic code parser.</param>
    public virtual ParserBase DecorateMarkupParser(ParserBase incomingMarkupParser) => incomingMarkupParser != null ? incomingMarkupParser : throw new ArgumentNullException(nameof (incomingMarkupParser));

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns the methods as language-specific Razor code generator.</summary>
    /// <returns>The methods as language-specific Razor code generator.</returns>
    /// <param name="incomingCodeGenerator">The C# or Visual Basic code generator.</param>
    public virtual RazorCodeGenerator DecorateCodeGenerator(
      RazorCodeGenerator incomingCodeGenerator)
    {
      return incomingCodeGenerator != null ? incomingCodeGenerator : throw new ArgumentNullException(nameof (incomingCodeGenerator));
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns this method to post all the processed generated code for the host.</summary>
    /// <param name="context">The code generator context.</param>
    public virtual void PostProcessGeneratedCode(CodeGeneratorContext context) => this.PostProcessGeneratedCode(context.CompileUnit, context.Namespace, context.GeneratedClass, context.TargetMethod);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns this method to post all the processed generated code for the host.</summary>
    /// <param name="codeCompileUnit">The code compile unit.</param>
    /// <param name="generatedNamespace">The generated namespace.</param>
    /// <param name="generatedClass">The generated class.</param>
    /// <param name="executeMethod">The execute method.</param>
    [Obsolete("This method is obsolete, use the override which takes a CodeGeneratorContext instead")]
    public virtual void PostProcessGeneratedCode(
      CodeCompileUnit codeCompileUnit,
      CodeNamespace generatedNamespace,
      CodeTypeDeclaration generatedClass,
      CodeMemberMethod executeMethod)
    {
      if (codeCompileUnit == null)
        throw new ArgumentNullException(nameof (codeCompileUnit));
      if (generatedNamespace == null)
        throw new ArgumentNullException(nameof (generatedNamespace));
      if (generatedClass == null)
        throw new ArgumentNullException(nameof (generatedClass));
      if (executeMethod == null)
        throw new ArgumentNullException(nameof (executeMethod));
    }
  }
}
